﻿<!--#include file="h.asp"-->
<%
'
'	七色虎建站系统
'	论坛发帖页面
'	2011.11.2

Sub main
	'发帖配置
	If Not ifNum(numTopicMin) Then numTopicMin="10"'帖子最少字数
	If Not ifNum(numTopicMax) Then numTopicMax="1000"'帖子最多字数

	Dim id,a,userid,b,count,rs,title,text,sql,author,now_,body_,title_,link_,sid_,length_,type_
	Dim formarray(3)
	checkLogin()'验证登录，要避免用户输入很多数据后发现自己没有登录
	checkUserPost()
	body_ = ""
	now_=time_now
	id=getN("id",1)
	a=getN("a", 0)
	b=getN("b", 0)
	userid=user_array(0)
	Select Case a
		Case 0:'发表帖子
			title_ = "发表帖子"
			formarray(0) = http_path&"bbs_post.asp?a=10||post||提交||标题<br/>"
			formarray(1) = "input||title$$$$20$$20||<br/>内容(支持"&hu.url("bbs_post.asp?id="&id&"&amp;a=-1","UBB")&")<br/>"
			formarray(2) = "area||text$$$$20$$"&numTopicMax&"||<br/>"
			formarray(3) = "hidden||id$$"&id&"||"&bbsSid&"$$"&sid&"||"
			If bbsFileUp="" Then bbsFileUp="1"'论坛默认允许文件上传
			If bbsFileUp="0" Then
				link_ = ""' 管理员已禁止文件上传
			Else
				sid_ = Replace(Replace(sid,"_1",""),"_3","")&"_3"
				link_ = "普通帖|<a href="""&http_path &"bbs_post.asp?a=7&amp;id="&id&"&amp;"&bbsSid&"="& sid_ &""">文件贴</a>"&_
					"|<a href="""&http_path &"bbs_post.asp?a=8&amp;id="&id&"&amp;"&bbsSid&"="& sid_ &""">图片贴</a><br/>"
			End If
			body_ = body_ & "[div=nav]-"&hu.url("?aid=index","首页")&"-"& hu.url("bbs_topic.asp?id="&id,"论坛")&"-发帖[/div]"&_
				link_& hu.getForm(formarray) & "<br/>[div=tip]温馨提示：<br/>1、标题字数不能超过20字<br/>"&_
				"2、内容字数"&numTopicMin&"~"&numTopicMax&"字[/div]"
		Case 10:'保存帖子
			title=getD("title","")
			text=getD("text","")
			title_ = "保存帖子"
			If title="" Or text="" Then rupt "错误", "标题和内容不能为空！"
			length_ = len(text)
			If length_<numTopicMin*1 Then rupt "错误", "内容字数必须大于"&numTopicMin&"！"
			If length_>numTopicMax*1 Then rupt "错误", "内容字数必须小于"&numTopicMax&"！"
			Set rs=hu.conn("select top 1 classid from 74hu_bbs where classid="&id)
			If Not rs.eof Then
				Set rs = hu.conn("select top 1 id from 74hu_topic where title='"&title&"' and content='"&text&"'")
				If rs.eof Then
					Dim timeInterval'防止刷帖,20秒发表一条;发帖间隔超过60s,加金币积分经验
					Set rs=hu.conn("select top 1 savetime from 74hu_topic where userid="&userid&" order by id desc")
					If Not rs.eof Then
						timeInterval = DateDiff("s", rs("savetime"), time_now)
						If timeInterval <20 Then rupt "错误", "为提高发帖质量,两次发帖间隔必须大于20秒!"
						If timeInterval >60 Then Call setUserAmount(userid, amtPost)'加金币积分经验
					End If
					sql = "insert into 74hu_topic (title,content,userid,classid,savetime,livetime,hit,reply,type,pid,[access],edittype)"&_
						"values('"&title&"','"&text&"',"&userid&","&id&",'"&time_now&"','"&time_now&"',0,0,0,0,0,0)"
					hu.conn(sql)
					hu.conn("update 74hu_user set topic=topic+1 where id="&userid)
					body_ = body_ & "发表成功！"
				Else
					body_ = body_ & "帖子已存在！请不要重复发表"
				End If
				body_ = body_ & hu.url("bbs_topic.asp?id="&id,"返回论坛")
			Else
				body_ = body_ & "没有这个论坛!"
			End If
		Case 7'发表文件贴
			title_ = "发表文件帖"
			'wap1.0访问则提示错误
			If hu.Style = 1 Then rupt "错误","当前浏览器不支持文件上传!"
			'论坛文件上传配置
			If bbsFileUp="" Then bbsFileUp="1"'论坛默认允许文件上传
			If bbsFileUp="0" Then rupt "错误","管理员已禁止文件上传!"
			If bbsFileType="" Then bbsFileType="rar|zip|gif|jpg|png|mp3|wma"'允许文件类型
			If Not ifNum(bbsFileSize) Then bbsFileSize="500"'论坛默认允许文件上传大小(k)
			body_ = body_ & "[div=nav]-"&hu.url("?aid=index","首页")&"-"& hu.url("bbs_topic.asp?id="&id,"论坛")&"-发帖[/div]"&_
				hu.url("bbs_post.asp?id="&id&"","普通帖")&"|文件贴"&"|"&hu.url("bbs_post.asp?id="&id&"&amp;a=8","图片帖")&"<br/>"&_
				"<form action=""bbs_upload.asp?"&sid_str&""" method=""post"" enctype=""multipart/form-data"" name=""fileform"">"&_
				"标题<br/><input name=""title"" maxlength=""20"" style=""width:180px;""/><br/>"&_
				"内容(支持"&hu.url("bbs_post.asp?id="&id&"&amp;a=-1","UBB")&")<br/><textarea name=""text"" cols=""20"" rows=""8""></textarea><br/>"&_
				"选择文件<br/><input type=""file"" name=""file""/><br/>下载需要"&bbsMoney&" <input name=""price"" value=""0"" maxlength=""3"" style=""width:50px;""/>"&_
				"<input type=""hidden"" name=""id"" value="""&id&"""/><br/><input type=""submit"" name=""submit"" value=""提交""/></form>"&_
				"<br/>[div=tip]温馨提示：<br/>1、标题字数不能超过20字<br/>2、内容字数"&numTopicMin&"~"&numTopicMax&"字<br/>"&_
				"3、上传文件单个最大"&bbsFileSize&"k<br/>4、允许格式："&Replace(bbsFileType,"|",",")&"[/div]"
		Case 8'发表图片贴
			title_ = "发表图片帖"
			'wap1.0访问则提示错误
			If hu.Style = 1 Then rupt "错误","当前浏览器不支持文件上传!"
			'论坛文件上传配置
			If bbsFileUp="" Then bbsFileUp="1"'论坛默认允许文件上传
			If bbsFileUp="0" Then rupt "错误","管理员已禁止文件上传!"
			If bbsFileType="" Then bbsFileType="rar|zip|gif|jpg|png|mp3|wma"'允许文件类型
			If Not ifNum(bbsFileSize) Then bbsFileSize="500"'论坛默认允许文件上传大小(k)
			body_ = body_ & "[div=nav]-"&hu.url("?aid=index","首页")&"-"& hu.url("bbs_topic.asp?id="&id,"论坛")&"-发帖[/div]"&_
				hu.url("bbs_post.asp?id="&id&"","普通帖")&"|"&hu.url("bbs_post.asp?id="&id&"&amp;a=7","文件帖")&"|图片贴<br/>"&_
				"<form action=""bbs_upimage.asp?"&sid_str&""" method=""post"" enctype=""multipart/form-data"" name=""fileform"">"&_
				"标题<br/><input name=""title"" maxlength=""20"" style=""width:180px;""/><br/>"&_
				"内容(支持"&hu.url("bbs_post.asp?id="&id&"&amp;a=-1","UBB")&")<br/><textarea name=""text"" cols=""20"" rows=""8""></textarea><br/>"&_
				"选择图片(至少选择一张)<br/><input type=""file"" name=""file""/><br/><input type=""file"" name=""file1""/><br/><input type=""file"" name=""file2""/>"&_
				"<input type=""hidden"" name=""id"" value="""&id&"""/><br/><input type=""submit"" name=""submit"" value=""提交""/></form>"&_
				"<br/>[div=tip]温馨提示：<br/>1、标题字数不能超过20字<br/>2、内容字数"&numTopicMin&"~"&numTopicMax&"字<br/>"&_
				"3、上传文件单个最大"&bbsFileSize&"k<br/>4、允许格式：gif,jpg,png,jpeg[/div]"
		Case 1:'编辑帖子
			title_ = "编辑帖子"
			body_ = body_ & "[div=nav]-"&hu.url("?aid=index", "首页")&"-" &hu.url("bbs_posts.asp?id="&id,"帖子")&"-编辑[/div]"
			Set rs=hu.conn("select t.title,t.content from 74hu_topic t inner join 74hu_bbs c on (t.classid=c.classid) where t.id="&id&" and (t.userid="&userid&" or c.host="&userid&")")
			If Not rs.eof Then
				formarray(0) = http_path&"bbs_post.asp?a=11||post||提交||帖子标题<br/>"
				formarray(1) = "input||title$$"&nowml(rs("title"))&"$$20$$20||<br/>内容(支持"&hu.url("bbs_post.asp?id="&id&"&amp;a=-1","UBB")&")<br/>"
				formarray(2) = "area||text$$"&nowml(rs("content"))&"$$20$$"&numTopicMax&"||<br/>"
				formarray(3) = "hidden||id$$"&id&"||"&bbsSid&"$$"&sid&"||"
				body_ = body_ & hu.getForm(formarray) & "<br/>温馨提示：<br/>标题最长20字，内容字数"&numTopicMin&"~"&numTopicMax&"字"
			Else
				body_ = body_ & "帖子不存在或者已删除!"
			End If
		Case 11:'编辑帖子
			title=getD("title","")
			text=getD("text","")
			title_ = "编辑帖子"
			body_ = body_ & "[div=nav]-"&hu.url("?aid=index","首页")&"-"&hu.url("bbs_posts.asp?id="&id,"帖子")&"-编辑[/div]"
			If title="" Or text="" Then rupt "错误", "标题和内容不能为空！"
			length_ = len(text)
			If length_<numTopicMin*1 Then rupt "错误", "内容字数必须大于"&numTopicMin&"！"
			If length_>numTopicMax*1 Then rupt "错误", "内容字数必须小于"&numTopicMax&"！"
			sql="update 74hu_topic t inner join 74hu_bbs c on (t.classid=c.classid) set t.title='"&title&"',t.content='"&text&"',"&_
				"t.edittime='"&now_&"',t.livetime='"&now_&"' where t.id="&id&" and (t.userid="&userid&" or c.host="&userid&")"
			hu.conn(sql)
			body_ = body_ & "编辑成功!<a href="""&http_path&"bbs_posts.asp?id="&id&"&amp;"&sid_str&""">返回帖子</a>"
		Case 2:'删除帖子
			title_ = "删除帖子"
			body_ = body_ & "[div=nav]-"&hu.url("?aid=index","首页")&"-"&hu.url("bbs_posts.asp?id="&id,"帖子")&"-删除[/div]"
			body_ = body_ & "你确定删除帖子?<br/>"&hu.url("bbs_post.asp?id="&id&"&amp;a=12","我确定")&"<br/>"& hu.url("bbs_posts.asp?id="&id,"返回原帖")
		Case 12:'删除帖子
			title_ = "删除帖子"
			body_ = body_ & "[div=nav]-"&hu.url("?aid=index", "首页") & "-删帖[/div]"
			Set rs=hu.conn("select t.userid,t.type from 74hu_topic t inner join 74hu_bbs c on (t.classid=c.classid) where t.id="&id&" and (t.userid="&userid&" or c.host="&userid&")")
			If Not rs.eof Then
				author=rs("userid")
				type_=rs("type")
				If type_<>1 And type_<>12 And type_<>13 Then
					hu.conn("delete from 74hu_topic where id="&id)
					Server.ScriptTimeOut=999999
					hu.conn("update 74hu_user set topic=topic-1 where id="&author)
					hu.conn("delete from 74hu_reply where postid="&id)'删除回复
					Call setUserAmount(userid, amtPostD)'扣金币积分经验
					body_ = body_ & "帖子删除成功!"
				Else
					body_ = body_ & "为了维护论坛的稳定,精华帖不能删除!"
				End If
			Else
				body_ = body_ & "帖子已删除!"
			End If
			Set rs=Nothing
		Case 3:'加精普通帖
			title_ = "帖子管理"
			body_ = body_ & "[div=nav]-"&hu.url("?aid=index","首页")&"-"&hu.url("bbs_posts.asp?id="&id,"帖子")&"-加精[/div]"
			sql="update 74hu_topic t inner join 74hu_bbs c on (t.classid=c.classid) set t.type=1,t.edittime='"&now_&"' where t.type=0 and t.id="&id&" and c.host="&userid
			hu.conn(sql)
			Call setUserAmount(userid, amtPostGood)'加金币积分经验
			body_ = body_ & "加精成功!"&hu.url("bbs_posts.asp?id="&id,"返回帖子")
		Case 32:'加精文件帖
			title_ = "帖子管理"
			body_ = body_ & "[div=nav]-"&hu.url("?aid=index","首页")&"-"&hu.url("bbs_posts.asp?id="&id,"帖子")&"-加精[/div]"
			sql="update 74hu_topic t inner join 74hu_bbs c on (t.classid=c.classid) set t.type=12,t.edittime='"&now_&"' where t.type=2 and t.id="&id&" and c.host="&userid
			hu.conn(sql)
			Call setUserAmount(userid, amtPostGood)'加金币积分经验
			body_ = body_ & "加精成功!"&hu.url("bbs_posts.asp?id="&id,"返回帖子")
		Case 33:'加精图片帖
			title_ = "帖子管理"
			body_ = body_ & "[div=nav]-"&hu.url("?aid=index","首页")&"-"&hu.url("bbs_posts.asp?id="&id,"帖子")&"-加精[/div]"
			sql="update 74hu_topic t inner join 74hu_bbs c on (t.classid=c.classid) set t.type=13,t.edittime='"&now_&"' where t.type=3 and t.id="&id&" and c.host="&userid
			hu.conn(sql)
			Call setUserAmount(userid, amtPostGood)'加金币积分经验
			body_ = body_ & "加精成功!"&hu.url("bbs_posts.asp?id="&id,"返回帖子")
		Case 4:'取消加精普通帖
			title_ = "帖子管理"
			body_ = body_ & "[div=nav]-"&hu.url("?aid=index","首页")&"-"&hu.url("bbs_posts.asp?id="&id,"帖子")&"-取消加精[/div]"
			sql="update 74hu_topic t inner join 74hu_bbs c on (t.classid=c.classid) set t.type=0 where t.type=1 and t.id="&id&" and c.host="&userid
			hu.conn(sql)
			Call setUserAmount(userid, amtPostGoodD)'扣金币积分经验
			body_ = body_ & "取消加精成功!"&hu.url("bbs_posts.asp?id="&id,"返回帖子")
		Case 42:'取消加精文件帖
			title_ = "帖子管理"
			body_ = body_ & "[div=nav]-"&hu.url("?aid=index","首页")&"-"&hu.url("bbs_posts.asp?id="&id,"帖子")&"-取消加精[/div]"
			sql="update 74hu_topic t inner join 74hu_bbs c on (t.classid=c.classid) set t.type=2 where t.type=12 and t.id="&id&" and c.host="&userid
			hu.conn(sql)
			Call setUserAmount(userid, amtPostGoodD)'扣金币积分经验
			body_ = body_ & "取消加精成功!"&hu.url("bbs_posts.asp?id="&id,"返回帖子")
		Case 43:'取消加精图片帖
			title_ = "帖子管理"
			body_ = body_ & "[div=nav]-"&hu.url("?aid=index","首页")&"-"&hu.url("bbs_posts.asp?id="&id,"帖子")&"-取消加精[/div]"
			sql="update 74hu_topic t inner join 74hu_bbs c on (t.classid=c.classid) set t.type=3 where t.type=13 and t.id="&id&" and c.host="&userid
			hu.conn(sql)
			Call setUserAmount(userid, amtPostGoodD)'扣金币积分经验
			body_ = body_ & "取消加精成功!"&hu.url("bbs_posts.asp?id="&id,"返回帖子")
		Case 5:'置顶帖子
			title_ = "帖子管理"
			body_ = body_ & "[div=nav]-"&hu.url("?aid=index","首页")&"-"&hu.url("bbs_posts.asp?id="&id,"帖子")&"-置顶[/div]"
			sql="update 74hu_topic t inner join 74hu_bbs c on (t.classid=c.classid) set t.pid=1 where t.id="&id&" and c.host="&userid
			hu.conn(sql)
			body_ = body_ & "置顶成功!<a href="""&http_path&"bbs_posts.asp?id="&id&"&amp;"&sid_str&""">返回帖子</a>"
		Case 6:'取消置顶帖子
			title_ = "帖子管理"
			body_ = body_ & "[div=nav]-"&hu.url("?aid=index","首页")&"-"&hu.url("bbs_posts.asp?id="&id,"帖子")&"-取消置顶[/div]"
			sql="update 74hu_topic t inner join 74hu_bbs c on (t.classid=c.classid) set t.pid=0 where t.id="&id&" and c.host="&userid
			hu.conn(sql)
			body_ = body_ & "取消置顶成功!"&hu.url("bbs_posts.asp?id="&id,"返回帖子")
		Case -1:'UBB说明
			title_ = "UBB功能"
			'TODO [buy=8]隐藏内容[/buy] 购买显示<br/>
			body_ = body_ & "[div=nav]-"&hu.url("?aid=index","首页")&"-UBB说明[/div]"&_
				"[br]或\\ 换行<br/>"&_
				"[url=网址]名字[/url] 链接<br/>"&_
				"[img]图片地址[/img] 图片<br/>-------<br/>"&_
				"[hide]隐藏内容[/hide] 登录显示<br/>"&_
				"-------<br/>"&_
				"[color=颜色]文字[/color] 彩色字<br/>"&_
				"[u]文字[/u] 带下划线的文字<br/>"&_
				"[s]文字[/s] 带删除线的文字<br/>"&_
				"[b]文字[/b] 加粗的文字<br/>"&_
				"[i]文字[/i] 倾斜的文字<br/>-------<br/>"&_
				"[sid] 防断线标识<br/>"&_
				"例子:http://xxx.com?[sid]<br/>结果:http://xxx.com?sid=XXX<br/>-------<br/>"&_
				"[username] 当前会员名字<br/>-------<br/>"&_
				"\wx 微笑"&showImg("face/wx")&" \sx 傻笑"&showImg("face/sx")&"<br/>"&_
				"\kl 可怜"&showImg("face/kl")&" \ot 呕吐"&showImg("face/ot")&"<br/>"&_
				"\bb 拜拜"&showImg("face/bb")&" \ll 流泪"&showImg("face/ll")&"<br/>"&_
				"\qq 亲亲"&showImg("face/qq")&" \wy 我晕"&showImg("face/wy")&"<br/>"&_
				"\yw 疑问"&showImg("face/yw")&" \bs 鄙视"&showImg("face/bs")&"<br/>"&_
				"\kb 抠鼻"&showImg("face/kb")&" \sj 睡觉"&showImg("face/sj")&"<br/>"&_
				"\mk 命苦"&showImg("face/mk")&" \lh 流汗"&showImg("face/lh")&"<br/>"&_
				"\jy 惊讶"&showImg("face/jy")&" \fn 愤怒"&showImg("face/fn")&""
	 End Select
	 hu.title = title_
	 hu.body = comUbb(body_)
End Sub

%>